﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Vim25Api;

namespace Wicresoft.EKA.VCenter.Tests
{
    [TestClass]
    public class EventsTest
    {
        [TestMethod]
        public void TestMethod1()
        {
            //OptionSpec url = new OptionSpec("url", "https://192.168.85.208/sdk");
            //OptionSpec url = new OptionSpec("url", "https://192.168.85.191/sdk");
            //OptionSpec url = new OptionSpec("url", "https://192.168.1.114/sdk");
            //OptionSpec userName = new OptionSpec("userName", "Administrator");
            //OptionSpec password = new OptionSpec("password", "Pass01!");
            //OptionSpec userName = new OptionSpec("userName", "root");
            //OptionSpec password = new OptionSpec("password", "Pass01!");


            OptionSpec url = new OptionSpec("url", "https://ws-vCenter-01/sdk");
            OptionSpec userName = new OptionSpec("userName", "Administrator");
            OptionSpec password = new OptionSpec("password", "P@ssw0rd");

            for (int i = 0; i < 100; i++)
            {
                ExtendedAppUtil app = ExtendedAppUtil.Initialize("Test", new OptionSpec[] { url, userName, password });
                app.Connect();
                ((IDisposable)app).Dispose();
            }


            //((IDisposable)app).Dispose();


            //AppUtil a = AppUtil.Initialize("Test", new OptionSpec[] { url, userName, password });
            //((IDisposable)a).Dispose();
            //app.Connect();



            //app.ServiceConnectionV25.ServiceContent.sessionManager

            //ManagedObjectReference vms = app.ServiceUtilV25.GetMoRef(null, "VirtualMachine", "vCenter_Server_2");

            //EventFilterSpec efs = new EventFilterSpec();
            ////EventFilterSpecByEntity efsEntry = new EventFilterSpecByEntity();
            ////efsEntry.entity =
            //efs.entity = new EventFilterSpecByEntity() { entity = vms };

            //ManagedObjectReference eventManager = app.ServiceConnectionV25.ServiceContent.eventManager;

            //Event[] events=app.ServiceConnectionV25.Service.QueryEvents(eventManager,efs);

            //ManagedObjectReference mo = app.ServiceUtilV25.GetMoRef(null, "Datstore", "Data");
            //Console.WriteLine(mo.ToString());
        }
    }
}
